﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Media;

namespace EpsiRisk.MoteurJeu
{
    public static class ClassSon
    {
        static SoundEffect Click;

        static Song BackMusic;

        public static float SoundsVolume;

        public static float BackMusicVolume
        {
            get
            {
                return MediaPlayer.Volume;
            }
            set
            {
                MediaPlayer.Volume = value;
            }
        }

        public static void initialiser(ContentManager content)
        {
            SoundsVolume = Settings.Default.SoundsVolume;
            BackMusicVolume = Settings.Default.BackMusicVolume;
            Click = content.Load<SoundEffect>("Sons/Click");
            BackMusic = content.Load<Song>("Sons/X-Ray Dog - 45 - Origins Of War Speed (Drums)");
            MediaPlayer.IsRepeating = true;
            playBackMusic();
        }

        /// <summary>
        /// joue le son d'un click
        /// </summary>
        public static void playclick()
        {
            Click.Play(SoundsVolume);
        }

        /// <summary>
        /// lance le fond sonore
        /// </summary>
        public static void playBackMusic()
        {
            if (MediaPlayer.State == MediaState.Paused)
            {
                MediaPlayer.Resume();
            }
            else
            {
                MediaPlayer.Play(BackMusic);
            }
            MediaPlayer.IsRepeating = true;
        }

        /// <summary>
        /// stop le fond sonore
        /// </summary>
        public static void stopBackMusic()
        {
            MediaPlayer.Pause();
        }

    }
}
